package com.proj.common.util;

import java.util.HashMap;

public class ResultData extends HashMap{
    //code msg data

    public ResultData(){
    }
    public ResultData(String code, String msg, Object data){
        this.put("code", code);
        this.put("msg", msg);
        this.put("data", data);
    }
//    public ResultData(String code, String msg, Object data,Object... objs){
//        this.put("code", code);
//        this.put("msg", msg);
//        this.put("data", data);
//        for(int i=0; i<objs.length; i+=2){
//            this.put(objs[i], objs[i+1]);
//        }
//    }
    public ResultData(Object... objs){
        for(int i=0; i<objs.length; i+=2){
            this.put(objs[i], objs[i+1]);
        }
    }

    public static ResultData success(){
        return new ResultData("code","200","msg","操作成功");
    }
    public static ResultData success(String code,String msg, Object data){
        return new ResultData(code,msg,data);
    }
    public static ResultData success(String msg,Object data){
        return new ResultData("200",msg,data);
    }
    public static ResultData success(Object data){
        return new ResultData("200","成功操作",data);
    }
    public static ResultData success(Object... objs){
        return new ResultData(objs);
    }


    public static ResultData fail500(String msg){
        return new ResultData("code","500","msg",msg);
    }
    public static ResultData fail500(){
        return new ResultData("code","500","msg","系统异常，请联系管理员");
    }
    public static ResultData fail400(String msg){
        return new ResultData("code","400","msg",msg);
    }
    public static ResultData fail400(){
        return new ResultData("code","400","msg","请求异常");
    }
    public static ResultData fail(String msg){
        return new ResultData("code","202","msg",msg);
    }
    public static ResultData fail(){
        return new ResultData("code","202");
    }


}
